<template>
    <div>
        <!--查询-->
        <div class="search-box">
            <el-form :inline="true" class="demo-form-inline" size="mini">

                <el-row>
                    <el-col :span="22">
                        <el-form-item label="入库单号">
                            <el-input placeholder="出库单号" v-model="search.idoCode"></el-input>
                        </el-form-item>

                        <el-form-item label="返厂从入库标志">
                            <el-select v-model="search.status" placeholder="返厂入库标志">
                                <el-option label="全部" value=""></el-option>
                                <el-option label="未入库" value=0></el-option>
                                <el-option label="已入库" value=1></el-option>
                            </el-select>
                        </el-form-item>

                        <el-form-item label="审核状态">
                            <el-select v-model="search.approveStatus" placeholder="审核状态">
                                <el-option label="全部" value=""></el-option>
                                <el-option label="审核未通过" value=0></el-option>
                                <el-option label="未审核" value=1></el-option>
                                <el-option label="已通过" value=2></el-option>
                            </el-select>
                        </el-form-item>

                        <el-form-item label="制单人">
                            <el-input placeholder="制单人" v-model="search.createBy"></el-input>
                        </el-form-item>


                        <el-form-item label="制单日期">
                            <el-date-picker
                                    v-model="createTime"
                                    @change="chooseTime"
                                    type="datetimerange"
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    range-separator="-"
                                    start-placeholder="开始日期"
                                    end-placeholder="结束日期"
                                    align="left">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="19">
                        <el-form-item label="审核日期">
                            <el-date-picker
                                    v-model="appTime"
                                    @change="applyChooseTime"
                                    type="datetimerange"
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    range-separator="-"
                                    start-placeholder="开始日期"
                                    end-placeholder="结束日期"
                                    align="left">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="5">
                        <el-form-item>
                            <el-button type="primary" @click="findPage" icon="el-icon-search">搜索</el-button>
                            <el-button type="warning" @click="resetForm" icon="el-icon-refresh-right">重置</el-button>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </div>

        <div class="button-box">
            <el-button type="success" @click="addApply" icon="el-icon-plus" size="small">新增入库申请单</el-button>
            <el-button type="danger" @click="delBatch" icon="el-icon-delete" size="small">删除</el-button>
        </div>
        <br>

        <!--展示-->
        <div class="table-box">
            <el-table height="400" border :data="applyList" :stripe="true" style="width: 100%"
                      @selection-change="handleSelectionChange">

                <el-table-column type="index" width="50" label="序号"></el-table-column>

                <el-table-column type="selection" width="55" :selectable="checkStatus"></el-table-column>

                <el-table-column prop="odoCode" label="返厂入库单号"></el-table-column>

                <el-table-column prop="status" label="返厂入库标志">
                    <template #default="slotProps">
                        <span v-if="slotProps.row.status===0">未入库</span>
                        <span v-if="slotProps.row.status===1">已入库</span>
                    </template>
                </el-table-column>

                <el-table-column prop="createBy" label="制单人"></el-table-column>

                <el-table-column prop="createTime" label="制单时间" :formatter="creatFormatter"></el-table-column>

                <el-table-column prop="approver" label="审批人"></el-table-column>

                <el-table-column prop="approverTime" label="审批时间" :formatter="approveFormatter"></el-table-column>

                <el-table-column prop="approveStatus" label="审批状态">
                    <template #default="slotProps">
                        <span v-if="slotProps.row.approveStatus===0" style="color: red">审核未通过</span>
                        <span v-if="slotProps.row.approveStatus===1">未审核</span>
                        <span v-if="slotProps.row.approveStatus===2">已通过</span>
                    </template>
                </el-table-column>

                <el-table-column label="操作">
                    <template #default="slotProps">
                        <el-button type="primary" round size="mini" @click="showInfo(slotProps.row.id)">查看</el-button>
                        <el-button type="warning" round size="mini" @click="alter(slotProps.row.id)"
                                   v-if="slotProps.row.approveStatus!==2">修改</el-button>
                    </template>
                </el-table-column>

            </el-table>
        </div>

        <!--分页组件-->
        <div class="page-box">
            <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="currentPage"
                    :page-sizes="[5, 10, 15, 20]"
                    :page-size="pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="total">
            </el-pagination>
        </div>

    </div>
</template>

<script>
    import refacinman from "./index";

    export default refacinman;
</script>

<style scoped src="./index.scss" lang="scss">

</style>